Waterloo ACM Programming Contest Fall 2
[and.git] / 11447 - Reservoir logs / 11447.cpp
blobad288425a64ba3e67641082f2bd3438aa9b558be
1 /*
2 Accepted
3 */
4 #include <stdio.h>
5 #include <assert.h>
6 #include <math.h>
8 #define MAXN 10001
9 #define EPS 1e-9
11 struct point{
12 double x, y;
15 point p[MAXN];
17 int main(){
18 int T, n, w;
19 double capacity, initial, out, in;
20 scanf("%d", &T);
21 while (T--){
22 scanf("%d", &n);
23 for (int i=0; i<n; ++i){
24 double x, y;
25 scanf("%lf %lf", &x, &y);
26 p[i].x = x; p[i].y = y;
28 scanf("%d", &w);
30 capacity = 0.0;
31 for (int i=0; i<n; ++i){
32 int j = (i+1)%n;
33 capacity += p[i].x*p[j].y - p[j].x*p[i].y;
35 capacity *= (double)w / 2;
37 assert(capacity > 0.0);
39 scanf("%lf %lf %lf", &initial, &out, &in);
41 initial = (capacity * initial) / 100.0; //Convert from percentage to volume
44 printf("Capacity es: %lf\n", capacity);
45 printf("Initial es: %lf\n", initial);
48 initial -= out;
49 if (initial < 0.0 - EPS){
50 printf("Lack of water. ");
51 initial = 0.0;
54 initial += in;
55 if (initial > capacity + EPS){
56 printf("Excess of water. ");
57 initial = capacity;
60 initial = (initial * 100.0) / capacity; //Convert from volume to percentage
62 int answer = initial;
63 printf("Final percentage: %d\%\n", answer);
65 return 0;